﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
''' <summary>
''' 设置预测的时间范围
''' </summary>
''' <remarks></remarks>
<Serializable()> Public Class TimeSetting
    Implements ICloneable


    Private m_SetDataPeroid As Boolean = False '指定气象数据处理期间标志
    Private m_StartTime As New DateTime(2007, 1, 1) '开始时间
    Private m_EndTime As New DateTime(2007, 12, 31) '结束时间
    Private m_SetHour As Boolean = False '设置小时的标志
    Private m_StartHour As Integer = 1 '开始小时
    Private m_EndHour As Integer = 24 '结束小时 aermod文件的开始时间是从1-24

    ''' <summary>
    ''' 指定气象数据处理期间标志
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property SetDataPeroid() As Boolean
        Get
            Return Me.m_SetDataPeroid
        End Get
        Set(ByVal value As Boolean)
            Me.m_SetDataPeroid = value
        End Set
    End Property
    ''' <summary>
    ''' 开始时间
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property StartTime() As DateTime
        Get
            Return Me.m_StartTime
        End Get
        Set(ByVal value As DateTime)
            Me.m_StartTime = value
        End Set
    End Property
    ''' <summary>
    ''' 开始小时
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property StartHour() As Integer
        Get
            Return Me.m_StartHour
        End Get
        Set(ByVal value As Integer)
            Me.m_StartHour = value
        End Set
    End Property
    ''' <summary>
    ''' 结束时间
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property EndTime() As DateTime
        Get
            Return Me.m_EndTime
        End Get
        Set(ByVal value As DateTime)
            Me.m_EndTime = value
        End Set
    End Property
    ''' <summary>
    ''' 结束小时
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property EndHour() As Integer
        Get
            Return Me.m_EndHour
        End Get
        Set(ByVal value As Integer)
            Me.m_EndHour = value
        End Set
    End Property
    ''' <summary>
    ''' 设置小时的标志
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property SetHour() As Boolean
        Get
            Return Me.m_SetHour
        End Get
        Set(ByVal value As Boolean)
            Me.m_SetHour = value
        End Set
    End Property
    ''' <summary>
    ''' 将从文件中获取的字符串转成常规气象数据
    ''' </summary>
    ''' <param name="strLine"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function ChangeStringdate(ByVal strLine As String) As DateTime     '根据给定的字符串，把字符串转化为时间数据
        Dim strYear As String = Mid(strLine, 1, 2)
        If CInt(strYear) < 10 Then '50年代以前的数据均为2000年
            strYear = "200" & CInt(strYear)
        ElseIf CInt(strYear) <= 50 Then
            strYear = "20" & CInt(strYear)
        Else
            strYear = "19" & CInt(strYear)
        End If
        '必选项
        Dim DateA As DateTime = New DateTime(CInt(strYear), CInt(Mid(strLine, 4, 2)), CInt(Mid(strLine, 7, 2)), CInt(Mid(strLine, 14, 2) - 1), 0, 0) '读取时间。由于文件是从1-24小时，所以减1，变成0-23小时。
        Return DateA
    End Function


    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New TimeSetting
        obj.m_SetDataPeroid = Me.m_SetDataPeroid '指定气象数据处理期间标志
        obj.m_StartTime = Me.m_StartTime '开始时间
        obj.m_StartHour = Me.m_StartHour '开始小时
        obj.m_EndTime = Me.m_EndTime '结束时间
        obj.m_EndHour = Me.m_EndHour  '结束小时 aermod文件的开始时间是从1-24
        obj.m_SetHour = Me.m_SetHour  '设置小时的标志
        Return obj

    End Function


    <OnDeserializing()> _
    Friend Sub OnDeserializingMethod(ByVal context As StreamingContext)

    End Sub

    <OnDeserialized()> _
    Friend Sub OnDeserializedMethod(ByVal context As StreamingContext)


    End Sub
End Class
